package com.lvt.example.thinking.in.spring.questions.L21.aop.example04;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Service;

/**
 * desc：class
 *
 * @author LT
 * @date 2022/10/24
 */
@Slf4j
@Aspect
@Service
public class AopConfig {
    @Before("execution(* com.lvt.example.thinking.in.spring.questions.L21.aop.example04.ElectricService.charge())")
    public void logBeforeMethod(JoinPoint pjp) throws Throwable {
        System.out.println("step into ->"+pjp.getSignature());
    }

    @Before("execution(* com.lvt.example.thinking.in.spring.questions.L21.aop.example04.ElectricService.charge()) ")
    public void calidateAuthority(JoinPoint pjp) throws Throwable {
        throw new RuntimeException("authority check failed.........");
    }

    @Before("execution(* com.lvt.example.thinking.in.spring.questions.L21.aop.example04.ElectricService.charge()) ")
    public void validateAuthority(JoinPoint pjp) throws Throwable {
        throw new RuntimeException("authority check failed");
    }
}